package be.ipl.pigolo.testUcc;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.junit.Before;
import org.junit.Test;

import be.ipl.pigolo.domaine.Partie;
import be.ipl.pigolo.usecases.GestionPartie;

public class TestCommencerPartie {

	private static GestionPartie gp ;
	private Partie partie ;

	
	@Before
	public void setUp() throws Exception {
		try {
			Context jndi = new InitialContext();
			gp = (GestionPartie) jndi
					.lookup("ejb:PigoloEAR/PigoloEJB/GestionPartieImpl!be.ipl.pigolo.usecases.GestionPartie");
			assertNotNull(gp);
		} catch (NamingException e) {
			e.printStackTrace();
		}
		
	}
	
	@Test
	public void testCommencerPartieVide(){
		assertNull(this.gp.commencerPartie(""));
	}
	
	@Test
	public void testCommencerPartieNonEnDB(){
		partie = new Partie("partie3", 5);
		assertNull(this.gp.commencerPartie("partie3"));
	}
	
	@Test
	public void testCommencerPartieValide(){
		partie = new Partie("partie4", 5);
		this.gp.creerPartie(partie.getNom(), 30);
		assertNotNull(this.gp.commencerPartie(this.partie.getNom()));
	}
	
}
